<html>

<head>

</head>

<body>
    <script>
        var asyncOperation = function (i) {
            return new Promise((resolve, reject) => {
                setTimeout(function () {
                    console.log('异步输出：', i);
                    resolve();
                }, 800);
            });

        };

        var array = ["第一步", "第二步", "第三步"];

        // for循环
        var forFun = async function () {
            for (let i = 0; i < array.length; i++) {
                await asyncOperation(array[i]); //等待异步操作完成
            }
            console.log("%cfor循环异步", 'color:orange');
        }
        forFun();

    </script>
</body>

</html>